<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./font/iconfont.css">
    <style>
        
        th,td{
            width: 200px;
            height: 50px;
            border: 1px solid black;
        }
        img{
            width: 100px;
            height: 50px;
        }
        tbody tr{
            /* 渐变色渲染 */
            background-image: linear-gradient(to right,orange,greenyellow);
        }
        /* 鼠标滑过 */
        tbody tr:hover{
            /* 渐变色渲染 */
            background-image: linear-gradient(to right,pink,yellow);
        }
    </style>
</head>
<body>
    <table align="center">
        <thead>
            <tr>
                <th>头像</th>
                <th>姓名</th>
                <th>年龄</th>
                <th>职业</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            
        </tbody>
    </table>
</body>
</html>
<script>
    var data=[
        {
            tx:'./蔡徐坤.webp',
            xm:'蔡徐坤',
            nl:26,
            zy:'歌手'
        },{
            tx:'./蔡徐坤.webp',
            xm:'蔡徐坤',
            nl:26,
            zy:'歌手'
        },{
            tx:'./蔡徐坤.webp',
            xm:'蔡徐坤',
            nl:26,
            zy:'歌手'
        },{
            tx:'./蔡徐坤.webp',
            xm:'蔡徐坤',
            nl:26,
            zy:'歌手'
        },{
            tx:'./蔡徐坤.webp',
            xm:'蔡徐坤',
            nl:26,
            zy:'歌手'
        }
    ]
    var tbody=document.querySelector('tbody')
    //循环遍历数组
    for(i=0;i<data.length;i++){
        //创建
        var tr=document.createElement('tr')
        //赋值
        tr.innerHTML=`
            <td><img src="${data[i].tx}"></td>
            <td>${data[i].xm}</td>
            <td>${data[i].nl}</td>
            <td>${data[i].zy}</td>
            <td><span class="iconfont icon-shanchu"></span><button>删除</button></td>
        `;
        //添加
        tbody.appendChild(tr)
    }
</script>